import { apiGet, apiPost, apiPut, apiDelete } from './client'

export interface ScoreItem {
  id?: number
  offeringId?: number
  name?: string
  type?: string
  maxScore?: number
  weight?: number
  standardJson?: string
}

export async function listScoreItems(params: { offeringId: number }) {
  return apiGet<ScoreItem[]>('/api/grades/score-items', params)
}

export async function createScoreItem(item: ScoreItem) {
  return apiPost<ScoreItem>('/api/grades/score-items', item)
}

export async function updateScoreItem(id: number, item: ScoreItem) {
  return apiPut<ScoreItem>(`/api/grades/score-items/${id}`, item)
}

export async function deleteScoreItem(id: number) {
  return apiDelete<string>(`/api/grades/score-items/${id}`)
}